﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SistemaControleOrcamentario
{
    public partial class RelLancamento : Form
    {
        public RelLancamento()
        {
            InitializeComponent();
            CarregarGrid();
        }

        private void CarregarGrid()
        {
            List<DataLayer.Model.Lancamento> list = DataLayer.Model.Lancamento.GetAll().OrderBy(p => p.DataPagamento).ToList();

            txtEntrada.Text = (from p in list
                               where p.Valor > 0
                               select p).Sum(y => y.Valor).ToString("c");

            txtSaida.Text = (from p in list
                               where p.Valor < 0
                               select p).Sum(y => y.Valor).ToString("c");

            txtTotal.Text = list.Sum(y => y.Valor).ToString("c");


            //decimal mesAnterior = (from p in list
            //                       where p.DataPagamento.Month < DateTime.Now.Month
            //                       select p).Sum(p => p.Valor);

            //txtTotalAnterior.Text = mesAnterior.ToString("c");

            //list = (from p in list
            //        where p.DataPagamento.Month == DateTime.Now.Month
            //        select p).ToList();

            //decimal total = list.Sum(p => p.Valor) + mesAnterior;

            //txtTotal.Text = total.ToString("c");
            dataGridView1.DataSource = list;
        }
    }
}
